package com.ineatconseil.yougo.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Class utils for provided date operations.
 * 
 * @author johanblo
 * 
 */
public final class DateUtils {

	/**
	 * The default format string value for date.
	 */
	private static final String DATE_FORMAT = "dd/MM/yyyy";

	/**
	 * The formatter used to convert a complete date with seconds.
	 */
	private static final String DATE_FORMAT_WITH_SECOND = "dd/MM/yyyy HH:mm:ss";

	/**
	 * The formatter use of convert Date to String.
	 */
	private static SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);

	/**
	 * The formatter use of convert Date to String.
	 */
	private static SimpleDateFormat sdf2 = new SimpleDateFormat(DATE_FORMAT_WITH_SECOND);

	/**
	 * Default constructor from superclass.
	 */
	private DateUtils() {
		super();
	}

	/**
	 * Format a given date to string.
	 * 
	 * @param dateToConvert
	 *            the date to convert.
	 * @param withHour
	 *            boolean used to check if there is an hour with the date.
	 * @return the string value of date.
	 */
	public static String convertDateToString(Date dateToConvert, boolean withHour) {

		if (withHour) {
			return sdf2.format(dateToConvert);
		} else {
			return sdf.format(dateToConvert);
		}

	}

	/**
	 * Get the current year.
	 * 
	 * @return value of the year.
	 */
	public static int getCurrentYear() {

		return Calendar.getInstance().get(Calendar.YEAR);

	}

	/**
	 * Get the current month.
	 * 
	 * @return value of the month.
	 */
	public static int getCurrentMonth() {

		return Calendar.getInstance().get(Calendar.MONTH) + 1;

	}

}
